package fastjson;

import com.alibaba.fastjson.JSON;

import java.util.*;

public class MapTest {
    public static void main(String[] args) {
        userMapTest();
    }
    public static void userMapTest() {
        User user = new User("方",23,"男");
        User user1 = new User("高",17,"女");
        User user2 = new User("雨",17,"女");
        List<User> userList = new ArrayList<>();
        List<User> userList1 = new ArrayList<>();
        userList.add(user);
        userList1.add(user1);
        userList1.add(user2);
        userList.addAll(userList1);
        System.out.println(userList);
        userList1.addAll(userList1);
        System.out.println(userList1);

        //set不可重复，list可以重复
        Set<User> userSet = new HashSet<>();
        userSet.add(user);
        userSet.add(user1);
        userSet.add(user);
        userSet.addAll(userSet);
        System.out.println("userSet"+userSet);



        HashMap<Object, Object> map = new HashMap<>();
        map.put(1,user);
        map.put(2,user1);
//        {1=User(name=方, age=23, Sex=男), 2=User(name=高, age=17, Sex=女)}
//        {1:{"age":23,"name":"方","sex":"男"},2:{"age":17,"name":"高","sex":"女"}}
        System.out.println(map);
        System.out.println(JSON.toJSONString(map));
        User user3 = JSON.parseObject(JSON.toJSONString(map.get(1)),User.class);
        System.out.println(user3);
//        //封装类型与基本类型比较会自动拆箱，如果封装类型为空会报指针
//        Integer integer = 90;
//        int i = integer.intValue();
//        System.out.println(i);

        System.out.println(Arrays.asList("831".split(",")).size());
    }
}
